package com.zhouheng.springbootdesignpattern.factorypattern;

public class ShapeFactory {

    /**
     * 使用 getShape 方法获取形状类型的对象
     * 一般这里要使用枚举值
     */
    public Shape getShape(String shapeType) {
        if (shapeType == null) {
            return null;
        }
        if ("CIRCLE".equalsIgnoreCase(shapeType)) {
            return new Circle();
        } else if ("RECTANGLE".equalsIgnoreCase(shapeType)) {
            return new Rectangle();
        } else if ("SQUARE".equalsIgnoreCase(shapeType)) {
            return new Square();
        }
        return null;
    }

}
